package contact.domain;

import java.util.List;

import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class DAOContact extends HibernateDaoSupport{
	
	public DAOContact(){}

	public static DAOContact createInstance(){
		return new DAOContact();
	}

	public Long create(Contact contact){
		return (Long) getHibernateTemplate().save(contact);
	}

	public Contact read(Long id){
		return (Contact) getHibernateTemplate().find("from Contact contact where contact.id = ?",id).get(0);
	}

	public List<Contact> readAll(){
		HibernateTemplate ht = getHibernateTemplate();
		return ht.find("from Contact");
	}

	public void update(Contact contact){
		getHibernateTemplate().update(contact);
	}

	public void delete (Contact contact){
		getHibernateTemplate().delete(contact);
	}

	public List readAllByContactCriteria(String field, String value){
		/*Criteria criteria = getSession().createCriteria(Contact.class);
		criteria.add(Restrictions.like(field, "%" + value + "%"));*/
		//DetachedCriteria criteria = DetachedCriteria.forClass(Contact.class).add(Property)
		//return getHibernateTemplate().findByCriteria(criteria);
		return null;
	}
	
	
	public List readAllByContactExample(Contact contact){
		/*Example example = Example.create(contact);
		Criteria criteria = session.createCriteria(Contact.class);
		criteria.add(example);
		return criteria.list();*/
		return null;
	}
}
